package assist.datastore.parser;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import assist.domain.model.Team;

/**
 * Creates a Team object for an NHL Team, based on the ID, nickname City, etc.
 *
 */
public class NHLTeamFactory
{
    private static List <Team> nhlTeams =
        new ArrayList<Team>();
    private static Map <String, Team> abbreviationsMap =
        new TreeMap<String, Team>();  
    
    private static Map <String, Team> fullNameMap =
        new TreeMap<String, Team>();     
    
    private static Map <Long, Team> teamIdMap =
        new TreeMap<Long, Team>(); 
    
    static
    {
        nhlTeams.add(new Team("Calgary", "Flames", "CGY", 20L));
        nhlTeams.add(new Team("Edmonton", "Oilers", "EDM", 22L));
        for(Team team : nhlTeams)
        {
            abbreviationsMap.put(team.getAbbreviation(), team);
        }
        for(Team team : nhlTeams)
        {
            fullNameMap.put(team.getFullName().toUpperCase(), team);
        }        
        for(Team team : nhlTeams)
        {
            teamIdMap.put(team.getTeamId(), team);
        }          
    }
    public static Team createFromAbbreviation(String abbreviation)
    {        
        return abbreviationsMap.get(abbreviation);
    }
    public static Team createFromFullName(String fullName)
    {        
        return fullNameMap.get(fullName.toUpperCase());
    }   
    public static Team createFromId(Integer id)
    {        
        return teamIdMap.get(id);
    }      
}
